package com.sc.VenusQueryBeta.ui.fragments.vip.child;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;

import com.hengjun.kingstar.sdk.base.fragment.BaseCompatFragment;
import com.hengjun.kingstar.sdk.utils.LogUtil;
import com.hengjun.kingstar.sdk.utils.LogUtils;
import com.hengjun.kingstar.sdk.utils.ToastUtils;
import com.sc.VenusQueryBeta.R;
import com.sc.VenusQueryBeta.constant.Constants;
import com.sc.VenusQueryBeta.model.bean.account.List;
import com.sc.VenusQueryBeta.model.bean.login.QueryRegisBean;
import com.sc.VenusQueryBeta.model.bean.login.UsersLoginBean;
import com.sc.VenusQueryBeta.ui.fragments.account.CurrencyFragment;
import com.sc.VenusQueryBeta.ui.fragments.account.xiugai.XiuGaiFragment;

import butterknife.BindView;
import butterknife.OnClick;
import io.reactivex.disposables.CompositeDisposable;

/**
 * 账户中所有功能
 */
public class VipUserFragment2 extends BaseCompatFragment {

    @BindView(R.id.about_vip_user_back)
    ImageButton aboutVipUserBack;
    @BindView(R.id.vip_user)
    TextView vipUser;
    @BindView(R.id.tv_jintieyongjin)
    TextView tvJintieyongjin;
    @BindView(R.id.tv_zhuanmamingxi)
    TextView tvZhuanmamingxi;
    @BindView(R.id.tv_cunkamingxi)
    TextView tvCunkamingxi;
    @BindView(R.id.tv_cun_dan)
    TextView tvCunDan;
    @BindView(R.id.tv_xiaofeixinxi)
    TextView tvXiaofeixinxi;
    @BindView(R.id.tv_daikuanxinxi)
    TextView tvDaikuanxinxi;
    @BindView(R.id.tv_ds)
    TextView tvDs;
    @BindView(R.id.tv_xxzm)
    TextView tvXxzm;
    @BindView(R.id.tv_xxdk)
    TextView tvXxdk;
    @BindView(R.id.tv_cm)
    TextView tvCm;
    @BindView(R.id.tv_xiugaimima)
    TextView tvXiugaimima;

    private QueryRegisBean queryRegisBean;
    private int clientindex;
    private String clientId;
    private static VipUserFragment2 fragment;
    private UsersLoginBean loginBean;
    private CompositeDisposable compositeDisposable;
    private int QueryType;

    public static VipUserFragment2 newInstance(int clientindex, QueryRegisBean mqueryregisbean, String clientid, List.Clients clients) {
        Bundle args = new Bundle();
        args.putInt(Constants.CLIENTINDEX, clientindex);
        args.putSerializable(Constants.QUERY_SETTING, mqueryregisbean);
        args.putString(Constants.CLIENTID, clientid);
        args.putSerializable(Constants.ACCOUNTLISTBEAN, clients);
        fragment = new VipUserFragment2();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (fragment.getArguments() != null) {
            queryRegisBean = (QueryRegisBean) fragment.getArguments().getSerializable(Constants.QUERY_SETTING);
            clientindex = fragment.getArguments().getInt(Constants.CLIENTINDEX, 0);
            clientId = fragment.getArguments().getString(Constants.CLIENTID);
            LogUtils.e("queryRegisBean.getServerSetting().getServerAddress()" + clientId);
        }
        compositeDisposable = new CompositeDisposable();
    }


    @Override
    public int getLayoutId() {
        return R.layout.activity_vip_user;
    }

    @Override
    public void initUI(View view, @Nullable Bundle savedInstanceState) {

        if (clientId != null) {
//            vipUser.setText(getString(R.string.hukou) + clientId);
            vipUser.setText("戶口" + clientId);
        }
        Bundle arguments = fragment.getArguments();
        if (arguments != null) {
            List.Clients maccountAccountListBean = (List.Clients) arguments.getSerializable(Constants.ACCOUNTLISTBEAN);
            if (maccountAccountListBean != null && !maccountAccountListBean.getClientgroupsCount().equals("0")) {//不等于0时候顯示下線
                tvXxzm.setVisibility(View.VISIBLE);
                tvXxdk.setVisibility(View.VISIBLE);
            } else {
//                ToastUtils.showToast("=="+maccountAccountListBean.getClientgroupsCount());
                tvXxzm.setVisibility(View.GONE);
                tvXxdk.setVisibility(View.GONE);
            }
        }
    }


    @OnClick({R.id.about_vip_user_back, R.id.tv_jintieyongjin, R.id.tv_zhuanmamingxi, R.id.tv_cunkamingxi, R.id.tv_cun_dan, R.id.tv_xiaofeixinxi, R.id.tv_daikuanxinxi, R.id.tv_ds, R.id.tv_xxzm, R.id.tv_xxdk, R.id.tv_cm, R.id.tv_xiugaimima})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.about_vip_user_back:
                pop();
                break;
            case R.id.tv_jintieyongjin://津贴佣金明细
//                Intent intent0 = new Intent(mActivity, JinTieActivity.class);
//                intent0.putExtra(Constants.QUERY_SETTING,queryRegisBean);
//                intent0.putExtra(Constants.CLIENTINDEX,clientindex);
//                intent0.putExtra(Constants.CLIENTID,clientId);
//                startActivity(intent0);
//                start(JinTieFragment.newInstance(queryRegisBean, clientindex, clientId),2);
                break;
            case R.id.tv_zhuanmamingxi://转码明细
//                Intent intent = new Intent(mActivity, ZhuanMaActivity.class);
//                intent.putExtra(Constants.QUERY_SETTING,queryRegisBean);
//                intent.putExtra(Constants.CLIENTINDEX,clientindex);
//                startActivity(intent);
                LogUtil.e("clientindex==========" + clientindex);
                QueryType = 0;
//                start(CurrencyFragment.newInstance(queryRegisBean, clientindex, clientId,QueryType),2);
                start(CurrencyFragment.newInstance(queryRegisBean, clientindex, QueryType), 2);
                break;
            case R.id.tv_cunkamingxi://存卡明细
//                Intent intent3 = new Intent(mActivity, CunKaActivity.class);
//                intent3.putExtra(Constants.QUERY_SETTING,queryRegisBean);
//                intent3.putExtra(Constants.CLIENTINDEX,clientindex);
//                startActivity(intent3);
                QueryType = 1;
                start(CurrencyFragment.newInstance(queryRegisBean, clientindex, QueryType), 2);

                break;
            case R.id.tv_cun_dan://存单明细
//                Intent intent4 = new Intent(mActivity, CunDanActivity.class);
//                intent4.putExtra(Constants.QUERY_SETTING,queryRegisBean);
//                intent4.putExtra(Constants.CLIENTINDEX,clientindex);
//                startActivity(intent4);
                QueryType = 7;
                start(CurrencyFragment.newInstance(queryRegisBean, clientindex, QueryType), 2);

                break;
            case R.id.tv_xiaofeixinxi://消费明细
//                Intent intent5 = new Intent(mActivity, XiaoFeiActivity.class);
//                intent5.putExtra(Constants.QUERY_SETTING,queryRegisBean);
//                intent5.putExtra(Constants.CLIENTINDEX,clientindex);
                QueryType = 2;
                start(CurrencyFragment.newInstance(queryRegisBean, clientindex, QueryType), 2);
                break;
            case R.id.tv_daikuanxinxi://贷款明细
//                Intent intent6 = new Intent(mActivity, DaiKuanActivity.class);
//                intent6.putExtra(Constants.QUERY_SETTING,queryRegisBean);
//                intent6.putExtra(Constants.CLIENTINDEX,clientindex);
//                startActivity(intent6);
                QueryType = 3;
                start(CurrencyFragment.newInstance(queryRegisBean, clientindex, QueryType), 2);

                break;
            case R.id.tv_ds://贷续明细
//                Intent intent7 = new Intent(mActivity, DaiShuActivity.class);
//                intent7.putExtra(Constants.QUERY_SETTING,queryRegisBean);
//                intent7.putExtra(Constants.CLIENTINDEX,clientindex);
//                startActivity(intent7);
                QueryType = -4;
                start(CurrencyFragment.newInstance(queryRegisBean, clientindex, QueryType), 2);
                break;
            case R.id.tv_xxzm://下线转码明细
//                Intent intent8 = new Intent(mActivity, XiaZhuanMaActivity.class);
//                intent8.putExtra(Constants.QUERY_SETTING,queryRegisBean);
//                intent8.putExtra(Constants.CLIENTINDEX,clientindex);
//                startActivity(intent8);
                QueryType = 4;
                start(CurrencyFragment.newInstance(queryRegisBean, clientindex, QueryType), 2);
                break;
            case R.id.tv_xxdk://下线贷款明细
//                Intent intent9 = new Intent(mActivity, XiaDaiKuanActivity.class);
//                intent9.putExtra(Constants.QUERY_SETTING,queryRegisBean);
//                intent9.putExtra(Constants.CLIENTINDEX,clientindex);
//                startActivity(intent9);
                QueryType = 5;
                start(CurrencyFragment.newInstance(queryRegisBean, clientindex, QueryType), 2);
                break;
            case R.id.tv_cm://场面明细
//                Intent intent10 = new Intent(mActivity, ChangmianActivity .class);
//                intent10.putExtra(Constants.QUERY_SETTING,queryRegisBean);
//                intent10.putExtra(Constants.CLIENTINDEX,clientindex);
//                startActivity(intent10);
                QueryType = 6;
                start(CurrencyFragment.newInstance(queryRegisBean, clientindex, QueryType), 2);
                break;
            case R.id.tv_xiugaimima://修改密码
//                Intent intent11 = new Intent(mActivity, XiuGaiActivity.class);
//                intent11.putExtra(Constants.QUERY_SETTING,queryRegisBean);
//                intent11.putExtra(Constants.CLIENTINDEX,clientindex);
//                startActivity(intent11);
                start(XiuGaiFragment.newInstance(queryRegisBean, clientindex), 2);
                break;
        }
    }
}
